package com.kcht.itsed.mws.persist.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kcht.itsed.mws.alemodel.LRSpec;
import com.kcht.itsed.mws.extendmodel.jpa.LogicReaderEntity;
import com.kcht.itsed.mws.extendmodel.jpa.SpecEntityConverter;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;
import java.util.Optional;

/**
 * 逻辑阅读器持久层
 * @author zhangwenshuo
 *
 */
public interface ILogicReaderDao extends BaseMapper<LogicReaderEntity> {

	@Select("select * from T_LOGIC_READER where LR_NAME=#{specName}")
	@Results(
			@Result(
					column = "LR_SPEC",
					property = "lrSpec",
					javaType = LRSpec.class,
					jdbcType = JdbcType.VARCHAR,
					typeHandler = SpecEntityConverter.class
			)
	)
	Optional<LogicReaderEntity> findBySpecName(String specName);

	@Select("select LR_NAME from T_LOGIC_READER")
	List<String> queryLogicReader();

	@Select("select * from T_LOGIC_READER")
	@Results(
			@Result(
					column = "LR_SPEC",
					property = "lrSpec",
					javaType = LRSpec.class,
					jdbcType = JdbcType.VARCHAR,
					typeHandler = SpecEntityConverter.class
			)
	)
	List<LogicReaderEntity> loadAllLogicalReaderEntities();
}
